<?php
/**
 * @author zhaofei
 * @package 产品model 
 * @createtime 2014-11-25
 * @updatetime 2014-11-25
 * @ps:no
 */
namespace System\Model;
use Think\Model;
class ProductsModel extends Model{

	protected $_validate =array(
		array('content','require','内容不能为空',1),
	);
	
	protected $_auto = array (
		array('uid','getuser',self::MODEL_INSERT,'callback'),
		array('uname','getname',self::MODEL_UPDATE,'callback'),
		array('createtime','time',self::MODEL_INSERT,'function'),
		array('token','gettoken',self::MODEL_INSERT,'callback'),
		array('updatetime','time',self::MODEL_BOTH,'function'),
		array('home','gethome',self::MODEL_BOTH,'callback'),
	);
	
	//获取分类
	public function getClassName($id,$string=''){
		$class = D('Products_class')->field('id,p_id,name')->where(array('id'=>$id))->find();
		if($class['p_id']>0){
			 $string=$string.' < '.$this->getClassName($class['p_id'],$class['name']);
		}else{
			 $string=$string.' < '.$class['name'].' ';
		}
		return $string;
	}

		

	 

	 
}
?>